﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace uban.demo.Protocol
{
    public class PenInputState
    {
        public byte Status { get; private set; }
        public byte Color { get; private set; }
        public short X { get; private set; }
        public short Y { get; private set; }
        public int Pressure;

        public PenInputState(byte[] raw)
        {
            Status = raw[0];
            Color = raw[1];
            if (raw[1] == 0x81)
            {
                X = (short)(raw[2] + (raw[3] << 8));
                Y = (short)(raw[4] + (raw[5] << 8));
                Pressure = 2047;
            }
            else
            {
                Pressure = 0;
            }
        }

        public override string ToString()
        {
            return $"横坐标={X},竖坐标={Y},压力={Pressure},状态={Status},演示={System.Drawing.Color.FromArgb(Color)}";
        }
    }
}
